﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Web.Views.LotteryPerson.Edit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>编辑</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../../Content/assets/css/admin/font.css">
    <link rel="stylesheet" href="../../Content/assets/lib/layui/css/layui.css"/>
	<link rel="stylesheet" href="../../Content/assets/css/admin/xadmin.css">
	<link rel="stylesheet" href="../../Content/assets/css/admin/Site.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-body ">
  <form class="layui-form">
				<input type="hidden" id="Identifier" name="Identifier"  />
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">参与者姓名</label>
				<div class="layui-input-inline">
				<input type="text" id="FullName" name="FullName" lay-verify="required" value="" autocomplete="off" class="layui-input"/>
			</div>
			</div>
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">头像图片</label>
				<div class="layui-input-inline">
				<input type="text" id="Avatar" name="Avatar"  value="" autocomplete="off" class="layui-input"/><button class="layui-btn" data-type="import"><i class="layui-icon"></i>上传</button> 
			</div>
			</div>
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">公司</label>
				<div class="layui-input-inline">
				<input type="text" id="Company" name="Company" value="" autocomplete="off" class="layui-input"/>
			</div>
			</div>
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">部门</label>
				<div class="layui-input-inline">
				<input type="text" id="Department" name="Department" value="" autocomplete="off" class="layui-input"/>
			</div>
			</div>
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">电话号码</label>
				<div class="layui-input-inline">
				<input type="text" id="Phone" name="Phone"  value="" autocomplete="off" class="layui-input"/>
			</div>
			</div>
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">是否参与 默认是不参与=2 参与=1</label>
				<div class="layui-input-inline">
				<input type="text" id="IsParticipator" name="IsParticipator" lay-verify="required" value="2" autocomplete="off" class="layui-input"/>
			</div>
			</div>
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">添加时间</label>
				<div class="layui-input-inline">
				<input type="text" id="AddDate" name="AddDate"  value="" autocomplete="off" class="layui-input"/>
			</div>
			</div>
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">添加用户</label>
				<div class="layui-input-inline">
				<input type="hidden" id="AddUser" name="AddUser"  value="admin" autocomplete="off" class="layui-input"/>
			</div>
			</div>
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">签到时间</label>
				<div class="layui-input-inline">
				<input type="hidden" id="SignInTime" name="SignInTime"  value="" autocomplete="off" class="layui-input"/>
			</div>
			</div>

    <div class="layui-form-item">
      <label for="L_repass" class="layui-form-label"> </label>
      <button  class="layui-btn bgcolor-blue" lay-filter="add" lay-submit="add"> 保存 </button>
    </div>
  </form>
</div>
    <script type="text/javascript" src="../../Content/assets/js/jquery.min.js"></script>
    <script src="../../Content/assets/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../Content/assets/lib/xadmin.js"></script>
<script>
    var controller = 'LotteryPerson';
    var winwidth = '858';
    var winheight = '800';
    function publish(url, data) {
        var murl = url;
        var index = layui.layer.open({
            type: 1
            , title: false //不显示标题栏
            , closeBtn: false
            , area: '300px;'
            , shade: 0.8
            , id: 'LAY_layuipro' //设定一个id，防止重复弹出
            , btnAlign: 'c'
            , moveType: 1 //拖拽模式，0或者1
            , content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">保存中....</div>'
            , success: function (layero) {
            }
        });
        $.post(murl, { data: JSON.stringify(data.field) }, function (result) {
            if (result.status) {
                layui.layer.close(index);
                layer.alert("保存成功", { icon: 6 }, function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    //parent.window.reloadtable();
                    //parent.window.reloadtable();
                    parent.window.location = parent.window.location;
                });

            } else {
                layui.layer.close(index);
                layer.alert(result.message);
            }

        }, 'json');
    }
    /*添加*/
    function add(title, url, w, h) {
        xadmin.open(title, url);
    }
    //初始化
    $(function () {
        var id='<%=ViewData["id"] %>';
        if(id){
        $.post('/'+controller+'/getEntityByID',{id:id},function(message){
                //var entity = '<%=ViewData["Entity"] %>';
            
            if(message.status==1)
            {
                var obj = message.data;
                $('#Identifier').val(obj.Identifier);
                $('#FullName').val(obj.FullName);
                $('#Avatar').val(obj.Avatar);
                $('#Company').val(obj.Company);
                $('#Department').val(obj.Department);
                $('#Phone').val(obj.Phone);
                $('#IsParticipator').val(obj.IsParticipator);
                $("#AddDate").val(obj.AddDate.substring(0, 19).replace("T", " "));
                $('#AddUser').val(obj.AddUser);
                $('#SignInTime').val(obj.SignInTime.substring(0, 19).replace("T", " "));
            }else{
                layer.alert(message.message);
            }
        },'json');
        }

    });

    layui.use(['form', 'laydate', 'element', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
          , layer = layui.layer
          ,laydate = layui.laydate; //弹出层;
        //数据处理
        var $ = layui.$, active = {
           import: function () { //验证是否全选
            add('导入', '/' + controller + '/Import', winwidth, winheight);
           }
        }
        //监听提交
        form.on('submit(add)', function (data) {
            console.log(data);
            publish('/LotteryPerson/save', data);
            //发异步，把数据提交给php

            return false;
        });
        form.on('submit(cancel)', function (data) {
            // 获得frame索引
            var index = parent.layer.getFrameIndex(window.name);
            //关闭当前frame
            parent.layer.close(index);

            return false;
        });


    });
    $(document).on('click', '.layui-table-view .layui-table-body tr', function (event) {
        var trElem = $(this);
        var tableView = trElem.closest('.layui-table-view');
        tableView.find('.layui-table-body tr.table_tr_click').removeClass('table_tr_click');
        tableView.find('.layui-table-body tr[data-index="' + trElem.data('index') + '"]').addClass('table_tr_click');
    });
</script>
</body>
</html>
